package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dao.EpidemicDaoEpidemicSpecialThingsDao;
import com.github.pagehelper.PageHelper;
import com.pojo.Epidemic;
import com.pojo.EpidemicSpecialThings;
import com.pojo.Users;
import com.service.EpidemicSpecialThingsServie;
import com.sun.javaws.IconUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author ZhaoJiaDong
 * @version 2020.1
 * @date 2022/11/25 0025 11:34
 */
@Service
public class EpidemicSpecialThingsServieImpl implements EpidemicSpecialThingsServie {
    @Autowired
    private EpidemicDaoEpidemicSpecialThingsDao epidemicDaoEpidemicSpecialThingsDao;
    @Override
    public List<EpidemicSpecialThings> findByPage(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<EpidemicSpecialThings> list = epidemicDaoEpidemicSpecialThingsDao.selectList(null);
        return list;
    }

    @Override
    public boolean add(EpidemicSpecialThings epidemicSpecialThings) {
        int count=epidemicDaoEpidemicSpecialThingsDao.insert(epidemicSpecialThings);
        return count<1?false:true;
    }

    @Override
    public boolean deleteById(Integer id) {
        //删除记录
        int count = epidemicDaoEpidemicSpecialThingsDao.deleteById(id);
        return count<1?false:true;
    }

    @Override
    public boolean updateImgById(Integer id,String img) {
        //根据id查询出记录
        EpidemicSpecialThings epidemicSpecialThings = epidemicDaoEpidemicSpecialThingsDao.selectById(id);
        //改变该记录的img
        epidemicSpecialThings.setImg(img);
        epidemicDaoEpidemicSpecialThingsDao.updateById(epidemicSpecialThings);
        return epidemicSpecialThings==null?false:true;
    }

    @Override
    public boolean update(EpidemicSpecialThings epidemicSpecialThings) {
        int count = epidemicDaoEpidemicSpecialThingsDao.updateById(epidemicSpecialThings);
        return count<1?false:true;
    }
}
